<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:csharp="http://csharp.org" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SitRep="urn:oasis:names:tc:emergency:EDXL:SitRep:1.0" xmlns:Person="urn:oasis:names:tc:emergency:edxl:ct:1.0" xmlns:PersonName="urn:oasis:names:tc:emergency:edxl:ciq:1.0:xnl">
	
	<msxsl:script language="CSharp" implements-prefix="csharp">
    <![CDATA[
	public String getPrefixedGUID(String prefix)
	{
		String id = System.Guid.NewGuid().ToString();
		return prefix+id;
	}
	

	public System.Collections.Generic.Dictionary<String,String> displayValues = new System.Collections.Generic.Dictionary<String, String>
	{
		{"TelephoneNetworkoutagesstatus",  "Telephone Network Outage Status"},
		{"InternetNetworkoutagestatus",  "Internet Network Outage Status"},
		{"SatelliteTVNetworkoutagestatus",  "Satellite TV Network Outage Status"},
		{"CableTVNetworkoutagestatus",  "Cable TV Network Outage Status"},
		{"CellProviderNetworkoutagestatus",  "Cell Provider Network Outage Status"},
		{"Dispatchcentersoutofservice",  "Dispatch Centers Out of Service"},
		{"Geographicareaswithlandlinetelephoneoutage",  "Georgraphic Areas with Landline Telephone Outage"},
		{"Geographicareaswithcellphoneoutage",  "Geographic Areas with Cell Phone Outage"},
		{"Status_restorationoftelecommunicationsinfrastructure",  "Restoration of Telecommunications Infrastructure Status"},
		{"Governmentbuildingsdamaged",  "Government Buildings Damaged"},
		{"Governmentbuildingsdestroyed",  "Government Buildings Destroyed"},
		{"Governmentbuildingsoperational",  "Government Buildings Operational"},
		{"Wateroutages_residential",  "Water Outages (Residential)"},
		{"Wateroutages_commercial",  "Water Outages (Commercial)"},
		{"Hourstowaterrestoration",  "Hours to Water Restoration"},
		{"Gasoutages_residential",  "Gas Outages (Residential)"},
		{"Gasoutages_commercial",  "Gas Outages (Commercial)"},
		{"Hourstogasrestoration",  "Hours to Gas Restoration"},
		{"Wastewatersystemsuseable",  "Waste Water System Useable?"},
		{"EOCLocationphysicallyaccessible",  "EOC Location Physically Accessible?"},
		{"CommunicationsEquipmentOperable",  "Communication Equipment Operable?"},
		{"Effectofincidentonproductionanddelivery",  "Effect of Incident on Production and Delivery?"},
		{"IrrigationWaterImpacted",  "Irrigation Water Impacted?"},
		{"Estimatedtimeuntilrestoration",  "Estimated Time Until Restoration"},
		{"Residentialcustomerswithoutpower",  "Residential Customers without Power"},
		{"Commercialcustomerswithoutpower",  "Commercial Customers without Power"},
		{"Availabilityofunleadedgasolineanddiesel",  "Availability of Unleaded + Diesel Gasoline?"},
		{"Statusofjailsandotherdetentioncenters",  "Status of Jails and other Detention Centers"},
		{"Policecommunicationsystemsfunctioning",  "Police Communication Systems Functioning?"},
		{"#Businessesdamaged",  "Businesses Damaged"},
		{"#Businessesdestroyed",  "Businesses Destroyed"},
		{"#Industrialplantsdamaged",  "Industrial Plants Damaged"},
		{"#Industrialplantsdestroyed",  "Industrial Plants Destroyed"},
		
		{"#CriticalRoadsclosed",  "Critical Roads Closed"},
		{"#EvacuationRoutesclosed",  "Evacuation Routes Closed"},
		{"#MajorAirfieldsclosed",  "Major Airfields Closed"},
		{"#Minorairfieldsclosed",  "Minor Airfields Closed"},
		{"BusLinesImpacted",  "Bus Lines Impacted"},
		{"Evacuationroutesopen",  "Evacuation Routes Open"},
		
		{"Currentresourcessufficient",  "Current Resources Sufficient?"},
		{"Sufficientcontractorresources",  "Sufficient Contractor Resources?"},
		{"Currentfireresourcessufficient",  "Current Fire Sources Sufficient?"},
		{"Prioritiesstatus",  "Priorities Status"},
		{"Potentialresourcesshourtfalls",  "Potential Resources Shortfalls"},
		{"Anticipatedrequirementformutualaidresources",  "Anticpiated Requirement for Mutual Aid Resources?"},
		{"Potentialsourcesforneededresources",  "Potential Sources for Needed Resources?"},
		{"Effectiveresponsetolifesafety911calls",  "Effective Response to Life Safety 911 Calls?"}, 
		{"Firecommunicationssystemsfunctioning",  "Fire Communication Systems Functioning?"},
		{"Adequatewaterpressureinsystem",  "Adequate Water Pressure in System?"},
		{"AdequateresponderPPE",  "Adequate Responder PPE?"},
		{"Sufficientrehab_psychologicalresources",  "Sufficient Rehab / Psychological Resources?"},
		{"Publicsafetyresourcesadequate",  "Public Safety Resources Adequate?"},
		{"ResponderPPEAdequate",  "Responder PPE Adequate?"},
		{"Majorissuestosuccessfulrecovery",  "Major Issues to Successful Recovery"},
		{"Effectivecommunicationwiththecommunity",  "Effective Communication within the Community?"},
		{"Talkingpoints",  "Talking Points"},
		{"Rumorsthatneedtobeaddressed",  "Rumors that need to be Addressed"}
	};
	
	public String getFriendlyLabel(String input)
	{
		
		
		String lastPart=input.Substring(input.LastIndexOf('/')+1);
		String shortened = displayValues[lastPart];
		if(shortened == null)
			return input;
		else
			return shortened;
	}
	]]>
  </msxsl:script>
	
	<xsl:template match="/">
	<!-- Leave this disabled when checking it in
	<script src="jquery-1.6.2.js"></script>
	-->
	
		
		
		<div id="$incidentID_$sitRepType_details" class="collapsableDetail">
			<ul>
				<li>
					<b>Infrastructure Affected</b>
				</li>
				<ul>
				
					
					<xsl:for-each select="SitRep:SitRep/SitRep:Report/SitRep:SituationSummary/SitRep:InfrastructureAffected">
						<li>
							<xsl:variable name="longLabel">
								<xsl:value-of select="SitRep:InfrastructureAffected/Person:ValueListURI"/>
							</xsl:variable>
							<b><xsl:value-of select="csharp:getFriendlyLabel($longLabel)"/></b> : <xsl:value-of select="SitRep:InfrastructureAffected/Person:Value"/>
						</li>
						
					</xsl:for-each>
					
				</ul>
				<li>
					<b>Transporation Systems</b>
				</li>
				<ul>
					
					<xsl:for-each select="SitRep:SitRep/SitRep:Report/SitRep:SituationSummary/SitRep:TransportationSystems">
						<li>
							<xsl:variable name="longLabel">
								<xsl:value-of select="Person:ValueKeyURI/Person:Value"/>
							</xsl:variable>
							<b><xsl:value-of select="csharp:getFriendlyLabel($longLabel)"/></b> : <xsl:value-of select="Person:PairValue"/>
						</li>
					</xsl:for-each>
					
				</ul>
				<li>
					<b>Decision Support Information</b>
				</li>
				<ul>
					<li><b>Projected number to be sheltered: </b><xsl:value-of select="SitRep:SitRep/SitRep:Report/SitRep:DecisionSupportInformation/SitRep:ProjectedNumberToBeSheltered"/>
					</li>
					
					<xsl:variable name="listId" select="csharp:getPrefixedGUID(&quot;listOfCriticalResourceNeeds&quot;)" /> 
					<div><xsl:attribute name="id"><xsl:copy-of select="$listId"/></xsl:attribute></div>
					
					<xsl:for-each select="SitRep:SitRep/SitRep:Report/SitRep:DecisionSupportInformation/SitRep:CriticalResourceNeeds">
						<li>
							<xsl:variable name="longLabel">
								<xsl:value-of select="Person:ValueKeyURI/Person:Value"/>
							</xsl:variable>
							<b><xsl:value-of select="csharp:getFriendlyLabel($longLabel)"/></b> : <xsl:value-of select="Person:PairValue"/>
						</li>
					</xsl:for-each>
					
				</ul>
			</ul>
		</div>
	</xsl:template>
	<xsl:template name="substring-after-last">
		<xsl:param name="string"/>
		<xsl:param name="delimiter"/>
		<xsl:choose>
			<xsl:when test="contains($string, $delimiter)">
				<xsl:call-template name="substring-after-last">
					<xsl:with-param name="string" select="substring-after($string, $delimiter)"/>
					<xsl:with-param name="delimiter" select="$delimiter"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$string"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
